package band.wukong.practice.javase.core.thread.basic;

/**
 * Desc: 通过实现Runnable接口来创建线程
 * Author: sunjs
 * Date: 2009-11-5 10:20:40
 */
public class Demo04 implements Runnable {
    private int a = 0;

    public void run() {
        for (a = 0; a < 30; a++) {
//            if (currentThread().getName().equals("Thread-1"))
            System.out.println(Thread.currentThread().getName() + ":" + a);
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Demo04 machine1 = new Demo04();
        Thread t1 = new Thread(machine1);
        Thread t2 = new Thread(machine1);
        t1.start();
        t2.start();
    }
}
